const path = require('path');
const webpack = require('webpack');

module.exports = {
  devtool: '#source-map',
  entry: {
    vendor: [
        path.join(__dirname, 'src/scripts/js/lib/angular.min.js'),
        path.join(__dirname, 'src/scripts/js/lib/angular-route.min.js'),
        path.join(__dirname, 'src/scripts/js/lib/angular-sanitize.js')
    ]
  },
  output: {
    path: path.join(__dirname, 'dist/scripts/js/lib'),
    filename: '[name].dll.js',
    /**
     * output.library
     * 将会定义为 window.${output.library}
     * 在这次的例子中，将会定义为`window.vendor_library`
     */
    library: '[name]_library',
    libraryTarget: 'umd',
    umdNamedDefine: true
  },
  plugins: [
    new webpack.DllPlugin({
      /**
       * path
       * 定义 manifest 文件生成的位置
       * [name]的部分由entry的名字替换
       */
      path: path.join(__dirname, 'dist/scripts/js/lib', '[name]-manifest.json'),
      /**
       * name
       * dll bundle 输出到那个全局变量上
       * 和 output.library 一样即可。 
       */
      name: '[name]_library'
    })
  ]
};